import { observable, action, makeObservable } from "mobx";
import { PageDateSelect } from '@/types/pages/enum'
import { IPurchaseMaterialFull } from "@/types/pages/purchase/interface";
import {getMaterialColumnChart,getPurchaseLineChart,getMaterialPieChart,getPurchaseMoneyData,getPurchaseNumData,getPurchasePieChart} from "@/api/purchaseMaterial";
import { IStore } from "@/types/pages/base";

/**
 * class Purchase
 * 原料采购
 */
class Purchase implements IStore<IPurchaseMaterialFull>   {
    @observable screenData: IPurchaseMaterialFull= {purchaseNum:{}, purchaseMoney:{}, materialPie:{}, purchasePie:{},materialColumn:{}, purchaseLine:{}}

    constructor() {
      makeObservable(this)
  }
   /**
     *
     * @param type 日期选择函数
     * @param date 传入日期
     */
     @action async getScreenData(type: PageDateSelect,date?:Date) {

        // 获取左上部分
        this.screenData.purchaseNum=await getPurchaseNumData(type,date);
        this.screenData.purchaseMoney= await getPurchaseMoneyData(type,date);
        this.screenData.purchasePie= await getPurchasePieChart(type,date);
        this.screenData.materialPie= await getMaterialPieChart(type,date);
        this.screenData.materialColumn=await  getMaterialColumnChart(type,date);
        this.screenData.purchaseLine=await  getPurchaseLineChart(type,date);
        return  this.screenData;
    }




}
export default Purchase;
